<%@ page contentType="text/html" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>SSE Demo</title>

</head>
<body>
<div id="msgFrompPush"></div>
<script src="js/jquery-3.2.0.min.js" type="text/javascript"></script>
<script type="text/javascript">


 if (!!window.EventSource) { //1
	   var source = new EventSource('push'); 
	   s='';
	   source.addEventListener('message', function(e) {//2
		   s+=e.data+"<br/>";
           console.log("connection open"+s);
	   });

	   source.addEventListener('open', function(e) {
	        console.log("connection open");
	   }, false);

	   source.addEventListener('error', function(e) {
	        if (e.readyState == EventSource.CLOSED) {
	           console.log("connection close");
	        } else {
	            console.log(e.readyState);    
	        }
	   }, false);
	} else {
	        console.log("你的浏览器不支持SSE");
	} 
</script>
</body>
</html>